package com.kbt.listener;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import com.kbt.util.data.StaticData;

import java.io.Serializable;
import java.util.Map;

/**
 * @author zhgk
 * @package: com.kbt.listener
 * @TODO: 点击时确定购物车的状态
 * @data: 2015/8/12 16:52
 * @version: V1.0
 */
public class ClickChangeCarStatusListener implements View.OnClickListener {
    private Activity nowActivity;
    private Class target;
    private Map<String, Object> params;
    private String carStatus = StaticData.GOOD_CAR_COMPLETE;


    public ClickChangeCarStatusListener(Activity activity, Class target, Map params, String carStatus) {
        this.nowActivity = activity;
        this.target = target;
        this.params = params;
        this.carStatus = carStatus;
    }

    @Override
    public void onClick(View v) {

        Intent intent = new Intent(nowActivity, target);
        Bundle bl = new Bundle();
        //处理参数
        for (Map.Entry<String, Object> entry : params.entrySet()) {
            bl.putSerializable(entry.getKey(), (Serializable) entry.getValue());
        }
        intent.putExtra("bundle", bl);
        nowActivity.startActivity(intent);
        nowActivity.finish();
    }
}
